import { getCity } from "../../utils/baiduMap";

// 同步action 
export const initCity = (value) => {
  return { type: "INITCITY", value }
}

// 异步获取当前的城市信息
export const initCityAsync = () => {
  return (dispatch) => { // initCityAsync 返回值是一个函数  const fun =initCityAsync()
    return getCity() // 获取到一个promise fun().then((res)=>{ res = 123 })
      .then(res => {
        dispatch({ type: "INITCITY", value: res.name.replace("市","") });
        // return 123;
      })
  }
}
// const a=()=>()=>()=>()=>()=>()=>123;